import { useState } from "react"

function Counter(){
  const [count,setCount]=useState(0)
  function increment(){
    setCount(count+1)
  }
  function decrement(){
    setCount(count-1)
  }
  // function increment(){
  //   setCount(c=>c+1)
  //   setCount(c=>c+1)
  //   setCount(c=>c+1)
  // }
  // function decrement(){
  //   setCount(c=>c-1)
  //   setCount(c=>c-1)
  //   setCount(c=>c-1)
  // }
  function guiling(){
    setCount(0)
  }
  return(
    <div className="counter">
      <p className="text">{count}</p>
      <button className="add" onClick={increment}>add</button>
      <button className="add" onClick={guiling}>guiling</button>
      <button className="add" onClick={decrement}>jianfa</button>
    </div>
  )
}
export default Counter